<template>
  <div> 
    
    <div class=" main-top">
      <div>
      <a-button icon="relaod" @click="loadData" style="margin-right:8px">刷新</a-button>
      <a-input-group compact>
                <a-input-search :allowClear="true" placeholder="按公司名称、项目名称模糊查询" v-model="keyword" @change="loadData" @search="loadData" />

                  
      </a-input-group> 
    </div>
    </div>
  <div id="attach" style="width: 100%; justify-content: center; display: flex">
   
    <div style="width: 100%;">
      <div>
        <a-table
          :columns="columns"
          :data-source="dataSource"
          rowKey="id"
          bordered
          :pagination="ipagination"
          @change="handleTableChange"
        >
          
        </a-table>
      </div>
    </div>
  </div>
  </div>
</template>

<script>
import { getAction } from '@/api/manage'
export default {
  components: {},
  props: {
   
    hteFile:{

      type: Object,
      default: res=>{return {}},
    },
    fileId :{
      default:0},
    
  },
  data() {
    return {
      columns: [
        {
          title: '年份',
          dataIndex: 'useYear',
          key: 'useYear',
        },
        {
          title: '法人公司',
          dataIndex: 'factoryName',
          key: 'factoryName',
        },
        {
          title: '项目名称',
          key: 'projectName',
          dataIndex: 'projectName',
        },
        {
          title: '项目经理',
          key: 'projectManager',
          dataIndex: 'projectManager',
        },
        {
          title: '利用结果',
          dataIndex: 'realCompletionSummary',
         
        },
      ],
      dataSource: [],
      urls: {
        list: '/lib/hteLibFile/queryPolicyUse',
      },
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条'
        },
        id: 0,
        total:0
      },
     keyword:'',
      
    }
  },
  created() {
    
  },
  mounted() {
     this.loadData()
  },
  methods: {
    /**
     * 获取历史版本列表
     */
    loadData() {
      let that = this
      let param = Object.assign({},this.ipagination);
      delete param.pageSizeOptions
      delete param.showTotal
      param.fileId = this.fileId;
      param.keyword = this.keyword;
      getAction(this.urls.list, param).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records || res.result
          if (res.result.total) {
            that.ipagination.total = res.result.total
          } else {
            that.ipagination.total = 0
          }
           that.$emit("getTotal",that.ipagination.total)
        }else{
          this.$message.warning(res.message)

        }
        
      })
    },
   
    /**
     * 表结构切换页码
     */
    handleTableChange(pagination, filters, sorter) {
      this.ipagination = pagination
      this.ipagination.pageNo = this.ipagination.current
      this.loadData()
    },
  },
}
</script>

<style lang="less" scoped>

.attr-box {
  width: 100%;
  /* display: flex;
  align-content: flex-start;
  flex-flow: row wrap; */
}

/* .attr-item {
  width: 50%;
  margin-bottom: 20px;
} */
.main-top{
   padding: 10px 0;
  padding-right: 80px;
  padding-left: 25px;
  background-color: #E9EBED;
  display: flex;
  align-items: center;
 
  >div{
    flex: 1;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
  }
  /deep/ .ant-input-group.ant-input-group-compact{
    min-width: 480px;
    width: 27vw;
    display: inline-block;
  }
}
</style>